<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of quanly_capdo
 *
 * @author Bui
 */
class Quantri_model extends CI_Model {

    private $tbl_quantri = 'gs7s_quantri';

    //put your code here

    public function __construct() {
        parent::__construct();
    }

    function count_all() {
        return $this->db->count_all($this->tbl_quantri);
    }

    function get_paged_list($limit = 10, $offset = 0) {
        $this->db->order_by('id', 'asc');
        return $this->db->get($this->tbl_quantri, $limit, $offset);
    }

    function get_data($id) {
        $this->load->database();
        $query = $this->db->get_where($this->tbl_quantri, array('id' => $id));
        return $query->result_array();
    }
    
    function get_by_id($id){
        $this->db->where('id', $id);
        return $this->db->get($this->tbl_quantri);
    }

    function add($data) {
        $this->db->insert($this->tbl_quantri, $data);
        return $this->db->insert_id();
    }

    function update($id, $data) {
        $this->load->database();
        $this->db->where('id', $id);
        $this->db->update($this->tbl_quantri, $data);
    }

    function delete($id) {
        $this->db->where('id', $id);
        $this->db->delete($this->tbl_quantri);
    }

}

?>
